<?php
/**
 * Created by JetBrains PhpStorm.
 * User: akrug
 * Date: 29.05.12
 * Time: 13:33
 * To change this template use File | Settings | File Templates.
 */

include_once('UcsMvc/AbstractForm.php');

class Form_User_Password extends UcsMvc_AbstractForm
{
    public $elementDecorators = array('ViewHelper', 'Errors','Label');

    protected $_language = 'de';

    public function init() {
        $this->setMethod('post');
        $this->setAction('');

        //Mehrsprachigkeit
        $this->_language = Zend_Registry::get('Zend_Locale')->getLanguage();
        $this->setTranslator(Zend_Registry::get('Zend_Translate'));

        $element = new Zend_Form_Element_Password('passwordOld');
        $this->addElement($element);

        $element = new Zend_Form_Element_Password('password');
        $element->setRequired(true)
                 ->addValidator('NotEmpty', true, array('messages'=>'Bitte geben Sie ein Passwort ein.'))
                 ->addValidator('stringLength', true, 8)
                 ->addValidator('Regex',true, array('pattern' => "/^[A-Za-z0-9[:punct:]]{8,}$/"))
                 ->addValidator('Regex',true, array('pattern' => "/[0-9]+/"))
                 ->addValidator('Regex',true, array('pattern' => "/[A-Za-z]+/"))
                 ->addValidator('Regex',true, array('pattern' => "/[[:punct:]]+/"))
                 ->addErrorMessage($this->_translator->translate('Passwort ist ungültig', $this->_language));
                 //->setDecorators($this->elementDecorators);
        $this->addElement($element);

        $element = new Zend_Form_Element_Password('passwordConfirm');
        $element->setRequired ( true )
                        ->addValidator('NotEmpty', true, array('messages'=>'Bitte geben Sie ein Passwort ein.'))
                        ->addValidator('identical', true, array('token' => 'password'))
                        ->addErrorMessage($this->_translator->translate('Passwortbestätigung ist ungültig', $this->_language));
                        //->setDecorators($this->elementDecorators);
        $this->addElement($element);
    }
}
